import 'package:flutter/material.dart';
import 'package:flutter_getx/view/home/components/home_list.dart';
import 'package:flutter_getx/view/home/components/home_nav.dart';
import 'package:get/get.dart';
import 'package:my_image/my_image.dart';

import 'logic.dart';
import 'state.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final HomeLogic logic = Get.put(HomeLogic());
  final HomeState state = Get.find<HomeLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: const Color.fromARGB(40, 13, 159, 233),
        appBar: AppBar(
          title: const Text('享+社区'),
          backgroundColor: Colors.blue,
          centerTitle: true,
        ),
        body: ListView(
          scrollDirection: Axis.vertical,
          padding: const EdgeInsets.all(10),
          children: [
            // 导航条
            const HomeNav(),
            // 中间广告图
            ClipRRect(
              borderRadius: BorderRadius.circular(10.0),
              child: Image.asset(ImgRes.imagesPng('images/banner@2x.jpg')),
            ),
            // 社区公告
            const HomeList()
          ],
        ));
  }

  @override
  void dispose() {
    Get.delete<HomeLogic>();
    super.dispose();
  }

  @override
  void initState() {
    super.initState();
    // 在这里可以添加初始化逻辑
    print('homePage: initState');
  }
}
